package com.gwl.common.advice;

import com.gwl.common.result.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionAdvice {

    /**
     * 处理系统异常，兜底处理所有的一切
     */
    @ExceptionHandler(value = Exception.class)
    public R defaultExceptionHandler(HttpServletRequest req, Throwable ex) {
        log.error("", ex);
        return R.fail("系统未知错误");
    }

}
